import React,{Component} from 'react';
import actions from '../../store/actions/session';
import {connect} from 'react-redux';
class Login extends Component{
	state={
		username:''
	}
	handleChange=(event) => {
		this.setState({username:event.target.value});	
	}
	handleSubmit=(event) => {
		event.preventDefault();
		this.props.login(this.state);
	}
	render() {
		return (
			<div className="row">
				<div className="col-md-12">
					<form onSubmit={this.handleSubmit}>
						<div className="form-group">
							<label htmlFor="username">用户名</label>
							<input value={this.state.username} onChange={this.handleChange} type="text" className="form-control"/>
						</div>
						<div className="form-group">
							<input type="submit" className="btn btn-primary"/>
						</div>
					</form>
					
				</div>
			</div>
		)
	}
}
export default connect(
	state => state.session,
	actions
)(Login)